package com.financing.wap.service.weixin.service;

import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.bean.kefu.WxMpKefuMessage;
import me.chanjar.weixin.mp.bean.result.WxMpOAuth2AccessToken;
import me.chanjar.weixin.mp.bean.result.WxMpUser;
import me.chanjar.weixin.mp.bean.subscribe.WxMpSubscribeMessage;

import com.financing.wap.common.ResultMap;
import com.financing.wap.dto.DstUserInfoDTO;

/**
 * @author Binary Wang
 */
public  interface WeixinService {


    /**
     * 统一获取AccessToken
     * @return
     * @throws WxErrorException
     */
    public String getAccessToken() throws WxErrorException;


    /**
     * 构建微信授权认证URL
     *
     * @param redirectURI 回调地址
     * @param scope
     * @param state
     * @return
     */
    public String buildAuthorizationUrl(String redirectURI, String scope, String state);

    public String subscribeMsgAuthorizationUrl(String redirectURI, Integer scope, String reserved);

    public boolean sendSubscribeMessage(WxMpSubscribeMessage subscribeMessage) throws WxErrorException;

    /**
     * 获得用户基本信息
     *
     * @param code
     * @return
     */
    public WxMpUser getUserInfo(String code) throws WxErrorException;


    /**
     * 获得用户基本信息
     *
     * @param code
     * @param lang
     * @return
     */
    public WxMpUser getUserInfo(String code, String lang) ;

    /**
     * 获得用户基本信息
     *
     * @param token
     * @param lang
     * @return
     */
    public WxMpUser getUserInfo(WxMpOAuth2AccessToken token, String lang);

    /**
     * 获得access token
     * <p>当用户同意授权后，会回调所设置的url并把authorization code传过来，然后用这个code获得access token，其中也包含用户的openid等信息</p>
     *
     * @param code
     * @return
     */
    public WxMpOAuth2AccessToken oauth2getAccessToken(String code) ;

    /**
     * 刷新access token
     *
     * @param wxMpOAuth2AccessToken
     * @return
     */
    public WxMpOAuth2AccessToken refreshAccessToken(WxMpOAuth2AccessToken wxMpOAuth2AccessToken) ;
    /**
     * 验证access token
     *
     * @param wxMpOAuth2AccessToken
     * @return
     */
    public boolean validateAccessToken(WxMpOAuth2AccessToken wxMpOAuth2AccessToken);
    /**
     * 保存信息到表-wx_mp_user
     * @param wxMpUser
     * @return
     */
    public Boolean saveMpUserToLocal(WxMpUser wxMpUser);

    /**
     * 获取-wx_mp_user
     * @param openId 公众号id
     * @return WxMpUserDTO
     */
    public DstUserInfoDTO queryWxMpUserByOpenId(String  openId);

    /**
     * 获取-wx_mp_user
     * @param unionId 开发平台唯一id
     * @return WxMpUserDTO
     */
    public DstUserInfoDTO queryWxMpUserByUnionId(String  unionId);

    /**
     *  客服接口-发消息
     * @param kefuMessage
     * @return
     * @throws WxErrorException
     */
    public boolean sendKefuMessage(WxMpKefuMessage kefuMessage) throws WxErrorException;


    public WxMpUser getUserInfoForUserService(String  openId) throws WxErrorException;

    /**
     * 获取
     * @param requestUrl
     * @param appid
     * @return WxMpUserDTO
     */
    public ResultMap getjsApiwxconfig(String  requestUrl, String appid) throws Exception;

    public String getFileByMediaId(String docFormat, String audioMediaId);
    
    public String qrCodePicture(String scene,String path) throws Exception;
    
}
